babl: make babl_model_with_space able to take format/model for space
authorØyvind Kolås <pippin@gimp.org>
Wed, 11 Jul 2018 21:23:08 +0000 (23:23 +0200)
committerØyvind Kolås <pippin@gimp.org>
Wed, 11 Jul 2018 21:23:08 +0000 (23:23 +0200)
babl/babl-model.c

index 2156059065345c49ca0f78286f40e2c068fd7261..d3471ed77afeb66789908e63c28d9182e27c1cf8 100644 (file)
@@ -374,6 +374,20 @@ babl_remodel_with_space (const Babl *model, const Babl *space)
   int i;
   assert (BABL_IS_BABL (model));
 
+  if (!space) space = babl_space ("sRGB");
+  if (space->class_type == BABL_FORMAT)
+  {
+    space = space->format.space;
+  }
+  else if (space->class_type == BABL_MODEL)
+  {
+    space = space->model.space;
+  }
+  else if (space->class_type != BABL_SPACE)
+  {
+    return NULL;
+  }
+
   if (model->model.space == space)
     return (void*)model;